define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/play_order/index' + location.search,
                    add_url: 'order/play_order/add',
                    edit_url: 'order/play_order/edit',
                    del_url: 'order/play_order/del',
                    multi_url: 'order/play_order/multi',
                    import_url: 'order/play_order/import',
                    table: 'play_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
                        {field: 'uid', title: __('Uid')},
                        {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
                        {field: 'info.name', title: __('Info.name'), operate: 'LIKE'},
                        {field: 'player.username', title: __('Player_id')},
                        {field: 'appoint_time', title: __('Appoint_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'project', title: __('Project'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'duration', title: __('Duration')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},
                        {field: 'pay_price', title: __('Pay_price'), operate:'BETWEEN'},
                        // {field: 'biz_id', title: __('Biz_id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'pay_type', title: __('Pay_type'),searchList: {"0":"未知","1":"支付宝",2:"微信"}, formatter: Table.api.formatter.status},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'latitude', title: __('Latitude'), operate:'BETWEEN'},
                        {field: 'longitude', title: __('Longitude'), operate:'BETWEEN'},
                        {field: 'status', title: __('Status'),searchList: {"0":"已取消","1":"已下单",2:"已支付",3:'已拒绝',4:'进行中',5:'已完成'}, formatter: Table.api.formatter.status},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
